;(function ($) {
    var attr = "select-sc-product"
        /**
         * 打开选择商品弹窗
         * @auhor 赵有文
         * @param option
         * @constructor
         */
    ;

    function OpenSelectProductLayer(option) {
        //  // debugger;
        var setting = {
            select: "single",//选择模式单选或多选
            fetchData: undefined//接收返回数据的方法
        };

        if (option != undefined) {
            $.extend(setting, option);
        }
        DGG.Layer.open("/sc/general/commonLayer/selectProduct.html", {
            title: "选择产品",
            area: ["35%", "30%"],
            btn: "",
            success: function (layer, index) {
                var fd = $(layer).find("iframe")[0].contentWindow.document;
                fd.selectType = setting.select;
                fd.fetchData = setting.fetchData;
            }
        });
    }

    $().ready(function () {
        $("input[" + attr + "]").eq(0).on("click", function () {
            var $input = $(this);
            $input.attr("readonly");
            OpenSelectProductLayer({
                select: "single", fetchData: function (data) {

                    $input.val(data.name);
                    $input.prev("input").val(data.id);
                }
            });

        });

    });

})(jQuery);


